from collections import OrderedDict
XUNKE_COVERED_BUSINESS_UNITS = ["Coin", "Day1mm", "Prex", "CoinFOF"]
XUNKE_COVERED_EXCHANGES = [
    "Binance", "Bybit", "Okex", "Gdax", "Dydx", "Kucoin", "Btcturk", "Bitbank", "Deribit"
]
XUNKE_SPOT_ONLY_EXCHANGES = ["Gdax", "Bitbank", "Btcturk"]
XUNKE_OPTIONS_EXCHANGES = ["Deribit"]
XUNKE_FUTURES_ONLY_EXCHANGES = ["Bybit", "Okex", "Kucoin", "Dydx"]
XUNKE_EXCLUDE_AGG_TYPES_EXCHANGES = ["Btcturk", "Bitbank", "Deribit"]

DIVIDER = """#####################################################"""

STAT_MAP = {
    "Binance VIP": {
        "mea": ["Futures.Binance.v1", "Futures.Binance.v1-delivery"],
        "backdays":
            "30D",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover_in_usd"],
        "eval_thold": [
            OrderedDict([
                ("VIP 9 (highest)", 25_000_000_000),
                ("VIP 8", 12_500_000_000),
                ("VIP 7", 5_000_000_000),
                ("VIP 6", 2_500_000_000),
                ("VIP 5", 1_000_000_000),
                ("VIP 4", 600_000_000),
                ("VIP 3", 100_000_000),
                ("VIP 2", 50_000_000),
                ("VIP 1", 15_000_000),
            ])
        ]
    },
    "Binance Spot MM": {
        "mea": ["Spot.Binance.v1"],
        "backdays":
            "WTD",
        "symbol_regex": [r".*"],
        "eval_metric": ["ms_maker"],
        "eval_thold": [
            OrderedDict([("Tier 4 (highest)", 0.0200), ("Tier 3", 0.0050), ("Tier 2", 0.0015),
                         ("Tier 1", 0.0005)])
        ]
    },
    "Binance USDs Futures MM": {
        "mea": ["Futures.Binance.v1", "Futures.Binance.v1-delivery"],
        "backdays":
            "WTD",
        "symbol_regex": [
            r"^(.*-USDT\.|.*-BUSD\.|.*-BTC\.)[\w.-]+$",
            r"^(?!BTC|ETH)(.*-USDT\.|.*-BUSD\.|.*-BTC\.)[\w.-]+$"
        ],
        "eval_metric": ["ms_maker", "ms_maker"],
        "eval_thold": [
            OrderedDict([("Tier 5 (highest)", 0.015), ("Tier 4", 0.0060), ("Tier 3", 0.0020),
                         ("Tier 2", 0.0008), ("Tier 1", 0.0004)]),
            OrderedDict([("Tier 5 (highest)", 0.015), ("Tier 4", 0.0060), ("Tier 3", 0.0020),
                         ("Tier 2", 0.0008), ("Tier 1", 0.0004)])
        ]
    },
    "Binance Coin-M Futures MM": {
        "mea": ["Futures.Binance.v1", "Futures.Binance.v1-delivery"],
        "backdays":
            "WTD",
        "symbol_regex": [
            r"^(?!.*-USDT\.|.*-BUSD\.|.*-BTC\.)[\w.-]+$",
            r"^(?!BTC|ETH)(?!.*-USDT\.|.*-BUSD\.|.*-BTC\.)[\w.-]+$"
        ],
        "eval_metric": ["ms_maker", "ms_maker"],
        "eval_thold": [
            OrderedDict([("Tier 3 (highest)", 0.015), ("Tier 2", 0.010), ("Tier 1", 0.008)]),
            OrderedDict([("Tier 3 (highest)", 0.0075), ("Tier 2", 0.005), ("Tier 1", 0.004)])
        ]
    },
    "Binance Futures Taker": {
        "mea": ["Futures.Binance.v1", "Futures.Binance.v1-delivery"],
        "backdays":
            "WTD",
        "symbol_regex": [
            r"^(.*-USDT\.|.*-BUSD\.)[\w.-]+$", r"^(BTC|ETH)(.*-USDT\.|.*-BUSD\.)[\w.-]+$",
            r"^(?!BTC|ETH)(.*-USDT\.|.*-BUSD\.)[\w.-]+$"
        ],
        "eval_metric": ["turnover_taker_in_usd", "ms_taker", "ms_taker"],
        "eval_thold": [
            OrderedDict([("Tier 4 (highest)", 5_000_000_000), ("Tier 3", 2_500_000_000),
                         ("Tier 2", 500_000_000), ("Tier 1", 250_000_000)]),
            OrderedDict([("Tier 4 (highest)", 0.02), ("Tier 3", 0.01), ("Tier 2", 0.002),
                         ("Tier 1", 0.001)]),
            OrderedDict([("Tier 4 (highest)", 0.02), ("Tier 3", 0.01), ("Tier 2", 0.002),
                         ("Tier 1", 0.001)])
        ],
    },
    "Bithumb Club B": {
        "mea": ["Spot.Bithumb.v2"],
        "backdays": "WTD",
        "symbol_regex": [r".*"],
        "eval_metric": ["ms_tvr_krw"],
        "eval_thold": [OrderedDict([
            ("Club B (highest)", 0.02),
        ])]
    },
    "Deribit Volume": {
        "mea": ["Options.Deribit.v2"],
        "backdays":
            "30D",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover_in_btc"],
        "eval_thold": [
            OrderedDict([
                ("VIP 3 (highest)", 50_000),
                ("VIP 2", 20_000),
                ("VIP 1", 5_000),
            ])
        ]
    },
    "Bybit MM": {
        "mea": ["Futures.Bybit.v3-linear"],
        "backdays": "MTD",
        "symbol_regex": [r"^(?!BTC-USDT\.PERPETUAL$|ETH-USDT\.PERPETUAL$).*$",],
        "eval_metric": ["ms_maker"],
        "eval_thold": [OrderedDict([("MM 3 (highest)", 0.015), ("MM 2", 0.005), ("MM 1", 0.001)]),]
    },
    "Okex MM": {
        "mea": ["Futures.Okex.v5", "Futures.Okex.v5-swap"],
        "backdays":
            "MTD",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover_in_usd"],
        "eval_thold": [
            OrderedDict([
                ("VIP 8 (highest)", 20_000_000_000),
                ("VIP 7", 2_000_000_000),
                ("VIP 6", 1_500_000_000),
                ("VIP 5", 1_000_000_000),
                ("VIP 4", 600_000_000),
                ("VIP 3", 200_000_000),
                ("VIP 2", 100_000_000),
                ("VIP 1", 50_000_000),
            ])
        ]
    },
    "Kucoin Futures MM": {
        "mea": ["Futures.Kucoin.v1"],
        "backdays": "MTD",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover_in_usd"],
        "eval_thold": [OrderedDict([("VIP (highest)", 30_000_000)])]
    },
    "Gdax MM": {
        "mea": ["Spot.Gdax.v1"],
        "backdays":
            "MTD",
        "symbol_regex": [r".*"],
        "eval_metric": ["ms_maker"],
        "eval_thold": [
            OrderedDict([("Tier 1 (highest)", 0.07), ("Tier 2", 0.025), ("Tier 3", 0.015),
                         ("Tier 4", 0.008)])
        ]
    },
    "Bitbank VIP": {
        "mea": ["Spot.Bitbank.v1"],
        "backdays":
            "MTD",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover_in_usd", "turnover"],
        "eval_thold": [
            OrderedDict([("VIP 8 (highest)", 222_000_000), ("VIP 7", 111_000_000),
                         ("VIP 6", 74_000_000), ("VIP 5", 44_000_000), ("VIP 4", 22_000_000),
                         ("VIP 3", 7_400_000), ("VIP 2", 2_960_000), ("VIP 1", 1_480_000)]),
            OrderedDict([("VIP 8 (highest)", 30_000_000_000), ("VIP 7", 15_000_000_000),
                         ("VIP 6", 10_000_000_000), ("VIP 5", 6_000_000_000),
                         ("VIP 4", 3_000_000_000), ("VIP 3", 1_000_000_000), ("VIP 2", 400_000_000),
                         ("VIP 1", 200_000_000)])
        ]
    },
    "Dydx MM": {
        "mea": ["Futures.Dydx.v3"],
        "backdays":
            "30D",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover_in_usd"],
        "eval_thold": [
            OrderedDict([("VIP (highest)", 200_000_000), ("Tier 5", 50_000_000),
                         ("Tier 4", 10_000_000), ("Tier 3", 5_000_000), ("Tier 2", 1_000_000)])
        ]
    },
    "Btcturk MM": {
        "mea": ["Spot.Btcturk.v1"],
        "backdays":
            "30D",
        "symbol_regex": [r".*"],
        "eval_metric": ["turnover"],
        "eval_thold": [
            OrderedDict([("Grade 5 (highest)", 200_000_000), ("Grade 4", 100_000_000),
                         ("Grade 3", 40_000_000), ("Grade 2", 10_000_000)])
        ]
    },
}
